import { ContentTypeEnum } from '@/enums/httpEnum';
import { defHttp } from '@/utils/http/axios';
import { CreateButtonParams, UpdateButtonParams, ButtonParams } from './model/systemModel';

enum Api {
  Button = '/button/',
  ButtonList = '/button/list',
  GetAll = '/button/list/all',
}

/**
 * 创建接口
 * @params CreateButtonParams
 * @returns Promise
 */
export const addButton = (params?: CreateButtonParams) =>
  defHttp.post(
    {
      url: Api.Button,
      headers: { 'Content-Type': ContentTypeEnum.FORM_DATA },
      params: params,
    },
    { isTransformResponse: false },
  );

/**
 * 更新接口
 * @param id
 * @param params
 * @returns
 */
export const updateButton = (id: Number, params?: UpdateButtonParams) =>
  defHttp.post(
    {
      url: `${Api.Button}/${id}`,
      params: params,
      headers: { 'Content-Type': ContentTypeEnum.FORM_DATA },
    },
    { isTransformResponse: false },
  );

/**
 * 接口列表
 * @param params ButtonParams
 * @returns
 */
export const getButtonList = (params?: ButtonParams) =>
  defHttp.get({ url: Api.ButtonList, params: params });

/**
 * 删除接口
 * @param ids
 * @returns
 */
export const deleteButtonIds = (ids: string) =>
  defHttp.delete<any>(
    {
      url: `${Api.Button}${ids}`,
    },
    { isTransformResponse: false },
  );

export const getAll = () => defHttp.get({ url: Api.GetAll });
